package com.raycloud.action.user;

import java.util.List;

import com.raycloud.action.common.BaseAction;
import com.raycloud.common.Constants;
import com.raycloud.domain.Msg;
import com.raycloud.domain.User;
import com.raycloud.manager.MsgMgr;
import com.raycloud.manager.UserMgr;

public class HomeAction extends BaseAction{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private UserMgr userMgr;
	private MsgMgr msgMgr;
	
	public String execute() throws Exception {
		User user = (User) session.get("user");
		if(user.getFollowCount() == 0) {
			//没用粉丝的用户推荐几个
			List<User> recommendUsers = userMgr.queryTopNUsers(10, user.getId());
			request.put("recommendUsers", recommendUsers);
		}
		
		List<Msg> msgs = msgMgr.queryUserMsgs(user, 0, Constants.MSG_FETCH_SIZE);
		request.put("msgs", msgs);
		
		return SUCCESS;
	}
	
	public void setUserMgr(UserMgr userMgr) {
		this.userMgr = userMgr;
	}

	public void setMsgMgr(MsgMgr msgMgr) {
		this.msgMgr = msgMgr;
	}
}
